<?php

class Admin_Model_Adminrole extends Zend_Db_Table_Abstract
{
    protected $_name = 'user_role';
    
    public function getDataByUserId ($userId){
    	$query = $this->select()
                        ->from($this->_name,array('roleId'))
                        ->where('userId = ?',(int)$userId);
        return $this->fetchAll($query);
    }
    public function addMultiData($userRole){
        $sql = 'INSERT INTO '.$this->_name.' (userId, roleId) VALUES '. implode(',', $userRole);
            
		$stmt = $this->getAdapter()->prepare($sql);
		$stmt->execute();
    }
    public function deleteData($userId){
        return $this->delete('userId = ' . (int) $userId);  
    }
    public function deleteDataByRoleId($roleId){
        return $this->delete('roleId = '.(int) $roleId);
    }
}

